
export const chinesePattern = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/

export const amountPattern = /^\d+(\.?\d{1,2})?$/

export const phonePattern = /^1[3-9]\d{9}$/

export const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/

export const loginRules = {
  username: [
    { required: true, message: '请输入账号', trigger: 'blur' },
    { pattern: /^[0-9a-zA-Z]+$/, message: '请输入正确的格式: 数字或英文字母', trigger: ['blur'] }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' },
    { pattern: /^[0-9a-zA-Z]+$/, message: '请输入正确的格式: 数字或英文字母', trigger: ['blur'] }
  ],
  phoneNumber: [
    { required: true, message: '请输入手机号', trigger: 'blur' },
    { pattern: phonePattern, message: '请输入正确的手机号格式', trigger: ['blur'] }
  ],
  email: [
    { required: true, message: '请输入邮箱地址', trigger: 'blur' },
    { pattern: emailPattern, message: '请输入正确的邮箱格式', trigger: ['blur'] }
  ],
  code: [
    { required: true, message: '请输入验证码', trigger: 'blur' },
    { pattern: /^\d{6}$/, message: '请输入6位数字验证码', trigger: ['blur'] }
  ]
}

export const foodRules = {
  name: [
    { required: true, message: '请输入名称', trigger: 'blur' },
    { pattern: new RegExp(chinesePattern), message: '请输入中英文或数字' }
  ],
  category: [
    { required: true, message: '请选择菜系', trigger: 'change' }
  ]
}

export const foodMaterialRules = {
  type: [
    { required: true, message: '请选择类型', trigger: 'change' }
  ],
  name: [
    { required: true, message: '请输入名称', trigger: 'blur' }
  ],
  amount: [
    { required: true, message: '请输入分量', trigger: 'blur' }
  ]
}

export const foodStepRules = {
  content: [
    { required: true, message: '请输入内容', trigger: 'blur' }
  ]
}

export const foodRecordRules = {
  name: [
    { required: true, message: '请选择菜谱名称', trigger: 'change' }
  ],
  date: [
    { required: true, message: '请选择完成时间', trigger: 'change' }
  ],
  person: [
    { required: true, message: '请选择完成人', trigger: 'change' }
  ],
  imageUrl: [
    { required: true, message: '请选择图片', trigger: 'change' }
  ]
}

export const foodMomentRules = {
  content: [
    { required: true, message: '请输入内容', trigger: 'blur' }
  ]
}

export const profileInfoRules = {
  username: [
    { required: true, message: '请输入用户姓名', trigger: 'blur' }
  ],
  phoneNumber: [
    { pattern: phonePattern, message: '请输入正确的手机号格式', trigger: ['blur'] }
  ],
  email: [
    { pattern: emailPattern, message: '请输入正确的邮箱格式', trigger: ['blur'] }
  ]
}


export const profilePasswordRules = {
  oldPassword: [
    { required: true, message: '请输入旧密码', trigger: 'blur' },
    { min: 6, max: 20, message: '请输入6~20位的密码', trigger: 'change' }
  ],
  newPassword: [
    { required: true, message: '请输入新密码', trigger: 'blur' },
    { min: 6, max: 20, message: '请输入6~20位的密码', trigger: 'change' }
  ],
  confirmPassword: [
    { required: true, message: '请输入确认密码', trigger: 'blur' },
    { min: 6, max: 20, message: '请输入6~20位的密码', trigger: 'change' }
  ]
}
